home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Tool Chest / Development Platforms / Macintosh Common Lisp Related / interfaces / PInterface Translator / PInterfaces / DatabaseAccess.p < prev    next >
Encoding:
Text File  |  1993-09-16  |  7.0 KB  |  258 lines  |  [TEXT/MPS ]

  1. {
  2.  
  3. Created: Monday, March 20, 1989 at 9:06 AM
  4.     DatabaseAccess.p
  5.     Pascal Interface to the Macintosh Libraries
  6.  
  7.     Copyright Apple Computer, Inc.     1989-1991
  8.     All rights reserved
  9.  
  10. }
  11.  
  12.  
  13. {$IFC UNDEFINED UsingIncludes}
  14. {$SETC UsingIncludes := 0}
  15. {$ENDC}
  16.  
  17. {$IFC NOT UsingIncludes}
  18.     UNIT DatabaseAccess;
  19.     INTERFACE
  20. {$ENDC}
  21.  
  22. {$IFC UNDEFINED UsingDatabaseAccess}
  23. {$SETC UsingDatabaseAccess := 1}
  24.  
  25. {$I+}
  26. {$SETC DatabaseAccessIncludes := UsingIncludes}
  27. {$SETC UsingIncludes := 1}
  28. {$IFC UNDEFINED UsingResources}
  29. {$I $$Shell(PInterfaces)Resources.p}
  30. {$ENDC}
  31. {$SETC UsingIncludes := DatabaseAccessIncludes}
  32.  
  33.  
  34. CONST
  35.  
  36. { error and status codes }
  37. rcDBNull = -800;
  38. rcDBValue = -801;
  39. rcDBError = -802;
  40. rcDBBadType = -803;
  41. rcDBBreak = -804;
  42. rcDBExec = -805;
  43. rcDBBadSessID = -806;
  44. rcDBBadSessNum = -807;        { bad session number for DBGetConnInfo }
  45.  
  46. rcDBBadDDEV = -808;         { bad ddev specified on DBInit }
  47.  
  48. rcDBAsyncNotSupp = -809;    { ddev does not support async calls }
  49. rcDBBadAsyncPB = -810;        { tried to kill a bad pb }
  50.  
  51. rcDBNoHandler = -811;        { no app handler for specified data type }
  52.  
  53. rcDBWrongVersion = -812;    { incompatible versions }
  54. rcDBPackNotInited = -813;    { attempt to call other routine before InitDBPack }
  55.  
  56. { messages for status functions for DBStartQuery }
  57. kDBUpdateWind    = 0;
  58. kDBAboutToInit    = 1;
  59. kDBInitComplete = 2;
  60. kDBSendComplete = 3;
  61. kDBExecComplete = 4;
  62. kDBStartQueryComplete = 5;
  63.  
  64. { messages for status functions for DBGetQueryResults }
  65. kDBGetItemComplete    = 6;
  66. kDBGetQueryResultsComplete = 7;
  67.  
  68. typeNone        = 'none';
  69. typeDate        = 'date';
  70. typeTime        = 'time';
  71. typeTimeStamp    = 'tims';
  72. typeDecimal     = 'deci';
  73. typeMoney        = 'mone';
  74. typeVChar        = 'vcha';
  75. typeVBin        = 'vbin';
  76. typeLChar        = 'lcha';
  77. typeLBin        = 'lbin';
  78. typeDiscard     = 'disc';
  79.  
  80. { "dummy" types for DBResultsToText }
  81. typeUnknown     = 'unkn';
  82. typeColBreak    = 'colb';
  83. typeRowBreak    = 'rowb';
  84.  
  85. { pass this in to DBGetItem for any data type }
  86. typeAnyType     = 0;
  87.  
  88. { infinite timeout value for DBGetItem }
  89. kDBWaitForever    = -1;
  90.  
  91. { flags for DBGetItem }
  92. kDBLastColFlag    = $0001;
  93. kDBNullFlag        = $0004;
  94.  
  95. TYPE
  96.  
  97. DBType = OSType;
  98.  
  99. { structure for asynchronous parameter block }
  100. DBAsyncParamBlockRec = RECORD
  101.     completionProc:     ProcPtr;    { pointer to completion routine }
  102.     result:             OSErr;        { result of call }
  103.     userRef:            LONGINT;    { for application's use }
  104.     ddevRef:            LONGINT;    { for ddev's use }
  105.     reserved:            LONGINT;    { for internal use }
  106.     END;
  107.  
  108. DBAsyncParmBlkPtr = ^DBAsyncParamBlockRec;
  109.  
  110. { structure for resource list in QueryRecord }
  111.  
  112. ResListElem = RECORD
  113.     theType:    ResType;
  114.     id:         INTEGER;
  115.     END;
  116.  
  117. ResListPtr = ^ResListArray;
  118. ResListHandle = ^ResListPtr;
  119. ResListArray = ARRAY [0..255] OF ResListElem;
  120.  
  121. { structure for query list in QueryRecord }
  122.  
  123. QueryListPtr = ^QueryArray;
  124. QueryListHandle = ^QueryListPtr;
  125. QueryArray = ARRAY [0..255] OF Handle;
  126.  
  127. QueryPtr = ^QueryRecord;
  128. QueryHandle = ^QueryPtr;
  129. QueryRecord = RECORD
  130.     version:        INTEGER;            { version }
  131.     id:             INTEGER;            { id of 'qrsc' this came from }
  132.     queryProc:        Handle;             { handle to query def proc }
  133.     ddevName:        Str63;                { ddev name }
  134.     host:            Str255;             { host name }
  135.     user:            Str255;             { user name }
  136.     password:        Str255;             { password }
  137.     connStr:        Str255;             { connection string }
  138.     currQuery:        INTEGER;            { index of current query }
  139.     numQueries:     INTEGER;            { number of queries in list }
  140.     queryList:        QueryListHandle;    { handle to array of handles to text }
  141.     numRes:         INTEGER;            { number of resources in list }
  142.     resList:        ResListHandle;        { handle to array of resource list elements }
  143.     dataHandle:     Handle;             { for use by query def proc }
  144.     refCon:         LONGINT;            { for use by application }
  145.     END;
  146.  
  147. { structure of column types array in ResultsRecord }
  148.  
  149. ColTypesPtr = ^ColTypesArray;
  150. ColTypesHandle = ^ColTypesPtr;
  151. ColTypesArray = ARRAY [0..255] OF DBType;
  152.  
  153. { structure for column info in ResultsRecord }
  154.  
  155. DBColInfoRecord = RECORD
  156.     len:            INTEGER;
  157.     places:            INTEGER;
  158.     flags:            INTEGER;
  159.     END;
  160.  
  161. ColInfoPtr = ^ColInfoArray;
  162. ColInfoHandle = ^ColInfoPtr;
  163. ColInfoArray = ARRAY [0..255] OF DBColInfoRecord;
  164.  
  165. ResultsRecord = RECORD
  166.     numRows:        INTEGER;            { number of rows in result }
  167.     numCols:        INTEGER;            { number of columns per row }
  168.     colTypes:        ColTypesHandle;     { data type array }
  169.     colData:        Handle;             { actual results }
  170.     colInfo:        ColInfoHandle;         { DBColInfoRecord array }
  171.     END;
  172.  
  173. FUNCTION InitDBPack : OSErr;
  174.     INLINE $3F3C,$0004,$303C,$0100,$A82F;
  175.  
  176. FUNCTION DBInit(VAR sessID : LONGINT; ddevName : Str63; host, user, passwd,
  177.         connStr : Str255; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  178.     INLINE $303C,$0E02,$A82F;
  179.  
  180. FUNCTION DBEnd(sessID : LONGINT; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  181.     INLINE $303C,$0403,$A82F;
  182.  
  183. FUNCTION DBGetConnInfo(sessID : LONGINT; sessNum : INTEGER;
  184.         VAR returnedID, version : LONGINT; VAR ddevName : Str63;
  185.         VAR host, user, network, connStr : Str255; VAR start : LONGINT;
  186.         VAR state : OSErr; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  187.     INLINE $303C,$1704,$A82F;
  188.  
  189. FUNCTION DBGetSessionNum(sessID : LONGINT; VAR sessNum : INTEGER;
  190.         asyncPB : DBAsyncParmBlkPtr) : OSErr;
  191.     INLINE $303C,$0605,$A82F;
  192.  
  193. FUNCTION DBSend(sessID : LONGINT; text : Ptr; len : INTEGER;
  194.         asyncPB : DBAsyncParmBlkPtr) : OSErr;
  195.     INLINE $303C,$0706,$A82F;
  196.  
  197. FUNCTION DBSendItem(sessID : LONGINT; dataType : DBType;
  198.         len, places, flags : INTEGER; buffer : Ptr; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  199.     INLINE $303C,$0B07,$A82F;
  200.  
  201. FUNCTION DBExec(sessID : LONGINT; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  202.     INLINE $303C,$0408,$A82F;
  203.  
  204. FUNCTION DBState(sessID : LONGINT; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  205.     INLINE $303C,$0409,$A82F;
  206.  
  207. FUNCTION DBGetErr(sessID : LONGINT; VAR err1, err2 : LONGINT; VAR item1, item2,
  208.         errorMsg : Str255; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  209.     INLINE $303C,$0E0A,$A82F;
  210.  
  211. FUNCTION DBBreak(sessID : LONGINT; abort : BOOLEAN; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  212.     INLINE $303C,$050B,$A82F;
  213.  
  214. FUNCTION DBGetItem(sessID, timeout : LONGINT; VAR dataType : DBType;
  215.         VAR len, places, flags : INTEGER; buffer : Ptr; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  216.     INLINE $303C,$100C,$A82F;
  217.  
  218. FUNCTION DBUnGetItem(sessID : LONGINT; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  219.     INLINE $303C,$040D,$A82F;
  220.  
  221. FUNCTION DBKill(asyncPB : DBAsyncParmBlkPtr) : OSErr;
  222.     INLINE $303C,$020E,$A82F;
  223.  
  224. FUNCTION DBGetNewQuery(queryID : INTEGER; VAR query : QueryHandle) : OSErr;
  225.     INLINE $303C,$030F,$A82F;
  226.  
  227. FUNCTION DBDisposeQuery(query : QueryHandle) : OSErr;
  228.     INLINE $303C,$0210,$A82F;
  229.  
  230. FUNCTION DBStartQuery(VAR sessID : LONGINT; query : QueryHandle;
  231.         statusProc : ProcPtr; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  232.     INLINE $303C,$0811,$A82F;
  233.  
  234. FUNCTION DBGetQueryResults(sessID : LONGINT; VAR results : ResultsRecord;
  235.         timeout : LONGINT; statusProc : ProcPtr; asyncPB : DBAsyncParmBlkPtr) : OSErr;
  236.     INLINE $303C,$0A12,$A82F;
  237.  
  238. FUNCTION DBResultsToText(results : ResultsRecord; VAR theText : Handle) : OSErr;
  239.     INLINE $303C,$0413,$A82F;
  240.  
  241. FUNCTION DBInstallResultHandler(dataType : DBType; theHandler : ProcPtr;
  242.         isSysHandler : BOOLEAN) : OSErr;
  243.     INLINE $303C,$0514,$A82F;
  244.  
  245. FUNCTION DBRemoveResultHandler(dataType : DBType) : OSErr;
  246.     INLINE $303C,$0215,$A82F;
  247.  
  248. FUNCTION DBGetResultHandler(dataType : DBType; VAR theHandler : ProcPtr;
  249.         getSysHandler : BOOLEAN) : OSErr;
  250.     INLINE $303C,$0516,$A82F;
  251.  
  252. {$ENDC}    { UsingDatabaseAccess }
  253.  
  254. {$IFC NOT UsingIncludes}
  255.     END.
  256. {$ENDC}
  257.  
  258.